﻿using RBAC.Repository.RabbitInterfae;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traceability.Domain;
using Traceability.Service.Interfae;

namespace Traceability.Service.Impl
{
    public class AdditiveService : IAdditiveService
    {
        private readonly IAdditiveRepository _Additiverepository;
        public AdditiveService(IAdditiveRepository additiverepository)
        {
            _Additiverepository = additiverepository;
        }
        /// <summary>
        /// 添加添加剂信息
        /// </summary>
        /// <param name="additive"></param>
        /// <returns></returns>
        public async Task<int> CreateAdditives(Additive additive)
        {
            return await _Additiverepository.AddAsync(additive);
        }
        /// <summary>
        /// 反填添加剂信息
        /// </summary>
        /// <param name="AdditiveId"></param>
        /// <returns></returns>
        public async Task<List<Additive>> GetAdditiveBy(string bath)
        {
            return await _Additiverepository.GetAsync(d => d.AdditiveBatch == bath);
        }
        /// <summary>
        /// 显示添加剂信息
        /// </summary>
        /// <param name="bacth"></param>
        /// <returns></returns>
        public async Task<List<Additive>> GetAdditiveList(int tid)
        {
            return await _Additiverepository.GetAsync(d => d.TraceabilityId==tid);
        }
        /// <summary>
        ///修改添加剂信息
        /// </summary>
        /// <param name="additive"></param>
        /// <returns></returns>
        public async Task<int> UpdateAdditive(Additive additive)
        {
           return await _Additiverepository.UpdateAsync(additive);
        }
    }
}
